package com.mega.ycy.mixin;

import com.mega.ycy.Yiciyuan_EVENT;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
@Mixin(value = EntityLivingBase.class, priority = -1145141919)
public abstract class EntityLivingBaseMixin extends Entity {
    public EntityLivingBaseMixin(World worldIn) {
        super(worldIn);
    }

    /**
     * @author getHealth
     */
    @Inject(method = "func_110143_aJ", at = @At("HEAD"), cancellable = true)
    public void getHealth(CallbackInfoReturnable<Float> cir) {
        if (Yiciyuan_EVENT.isDeath(this))
            cir.setReturnValue(0F);
    }

    /**
     * @author isAlive
     */
    @Inject(method = "func_70089_S", at = @At("HEAD"), cancellable = true)
    public void isAlive(CallbackInfoReturnable<Boolean> cir) {
        if (Yiciyuan_EVENT.isDeath(this))
            cir.setReturnValue(false);
    }
}
